@echo off
mkdir logs

set logfile=logs\view_%2_%db2_server_name%.out

db2 describe table %1.%2 show detail >%logfile%

echo  -----------------------------------------below is (are) pk-------------------------  >>%logfile%
db2 -x "select LTRIM(RTRIM(sp.column_name))||' '|| LTRIM(RTRIM(co.TYPENAME)) || '(' || LTRIM(RTRIM(CHAR(co.LENGTH))) || ')',sp.table_schem from sysibm.sqlprimarykeys sp, SYSCAT.COLUMNS co where sp.table_name=upper('%2') and sp.table_name=co.TABNAME and sp.column_name = co.COLNAME" >>%logfile%

echo  -----------------------------------------below are the first 20 rows in the %1.%2 table---------  >>%logfile%
db2 -x select * from %1.%2 fetch first 20 rows only >>%logfile%

echo ------------------index---------------------------------------- >>%logfile%
db2 describe indexes for table %1.%2 >>%logfile%

echo  -----------------------below is the sql of the %1.%2 view ---------  >>%logfile%
db2 -x select varchar(text,32670)  from syscat.views where viewschema=upper('%1')and viewname = upper('%2') >>%logfile%

echo -------------------------get tables in a view ---------------------  >>%logfile%
db2 -x select distinct bname from syscat.viewdep where viewname=upper('%2')  and btype='T' >>%logfile%
start  %logfile%
